StoreRoomForm= Ext
		.extend(
				Ext.Window,
				{
					formPanel : null,
					constructor : function(a) {
						Ext.applyIf(this, a);
						this.initUIComponents();
						StoreRoomForm.superclass.constructor.call(this, {
							layout : "fit",
							items : this.formPanel,
							modal : true,
							id : "StoreRoomFormWin",
							title : "库房管理",
							iconCls : "menu-storeRoom",
							width : 370,
							height : 200,
							buttonAlign : "center",
							buttons : this.buttons
						});
					},
					initUIComponents : function() {
						this.formPanel = new Ext.FormPanel({
							url : __ctxPath
							+ "/system/saveStoreRoom.do",
							layout : "form",
							id : "StoreRoomForm",
							border : false,
							bodyStyle : "padding:5px;",
							defaults : {
								anchor : "96%,96%"
							},
							formId : "StoreRoomFormId",
							defaultType : "textfield",
							items : [ {
								name : "storeRoom.id",
								xtype : "hidden",
								value : this.id == null ? "" : this.id
							}, {
								fieldLabel : "库房名称"+'<font color=red>*</font>',								
								name : "storeRoom.storeRoomName",
								allowBlank : false,
								blankText : "库房名称为空"	
							}, {
								xtype : "combo",
								fieldLabel: '库房分类'+'<font color=red>*</font>', 
								editable : false,
								allowBlank : false,
								width:150,
								id : "storeRoom.storeRoomType.detailId",
								hiddenName : "storeRoom.storeRoomType.detailId",
								name : "storeRoom.storeRoomType.codeName",
								mode : "local",
								lazyInit : false,
								forceSelection : false,
								blankText : '请选择库房类别', 
								emptyText : '请选择库房类别', 			
								triggerAction : "all",
								store : new Ext.data.JsonStore({
									url : __ctxPath + "/system/listDicDetail.do?Q_dicType.dic_S_EQ=库房类别",
									autoLoad : true,
									autoShow : true,
									root : "result",
									idProperty : "detailId",
									fields : [ "detailId", "codeName" ],
									listeners :{   
				        			      load:function(){    
				        			      Ext.getCmp('storeRoom.storeRoomType.detailId').setValue(Ext.getCmp('storeRoom.storeRoomType.detailId').getValue());  
				        			      }  
				            			}
								}),
								valueField : "detailId",
								displayField : "codeName"			
							}, {
								fieldLabel : "备注",
								xtype : "textarea",
								name : "storeRoom.remark"
							}]
						});
						if (this.id != null && this.id != "undefined") {
							this.formPanel.loadData({
								url : __ctxPath
										+ "/system/getStoreRoom.do?id="
										+ this.id,
								preName : "storeRoom",
								root : "result",
								success :function(form,action){
									var obj = Ext.decode(form.responseText).result;
									Ext.getCmp("StoreRoomForm").getForm().findField("storeRoom.storeRoomType.detailId").setValue(obj.storeRoomType.detailId);
			            			}
							});
						}
						this.buttons = [ {
							text : "保存",
							iconCls : "btn-save",
							scope : this,
							handler : this.save.createCallback(this)
						}, {
							text : "取消",
							iconCls : "btn-cancel",
							scope : this,
							handler : function() {
								this.close();
							}
						} ];
					},
					save : function() {
						var b = Ext.getCmp("StoreRoomForm");
						if (b.getForm().isValid()) {
							b.getForm().submit({								
								method : "post",
								waitMsg : "正在提交数据...",
								success : function(c, d) {
									var result=Ext.util.JSON.decode(d.response.responseText);
									if(result.success){
										Ext.ux.Toast.msg("操作提示","信息保存成功！");
										Ext.getCmp("StoreRoomFormWin").close();
										Ext.getCmp("StoreRoomGrid").getStore().reload();										
										}else{
										Ext.MessageBox.show({
											title : "操作信息",
											msg : result.msg,
											buttons : Ext.MessageBox.OK,
											icon : "ext-mb-error"
										});
										Ext.getCmp("StoreRoomFormWin").close();
										Ext.getCmp("StoreRoomGrid").getStore().reload();
										
									}
								},
								failure : function(c, d) {
									var result=Ext.util.JSON.decode(d.response.responseText); 
									Ext.MessageBox.show({
										title : "操作提示",
										msg : result.msg,
										buttons : Ext.MessageBox.OK,
										icon : "ext-mb-error"
									});
								}
							});
						}
						
					}
				});